/*
	Copyright 2007-2010 Petr Ohlidal

	This file is a part of GrobMaker

	GrobMaker is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	GrobMaker is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with GrobMaker.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GROBMAKER_AREA
#define GROBMAKER_AREA

/** @file */

#include "Vector.hpp"
#include "Rectangle.hpp"

namespace GrobMaker{

struct Area{
	float x,y,w,h;

	Area(float x_,float y_,float w_, float h_):
		x(x_), y(y_), w(w_), h(h_){
	}

	Area(){
	}

	Area(const Rectangle& rect){
		this->x=static_cast<float>(rect.x);
		this->y=static_cast<float>(rect.y);
		this->w=static_cast<float>(rect.w);
		this->h=static_cast<float>(rect.h);
	}

	Area scale(float w1, float h1, float w2, float h2) const{
		return Area( (x/w1)*w2, (y/h1)*h2, (w/w1)*w2, (h/h1)*h2 );
	}

	Area scale(int w1, int h1, int w2, int h2) const{
		return this->scale(static_cast<float>(w1),static_cast<float>(h1),
			static_cast<float>(w2),static_cast<float>(h2));
	}

	Vector getCenter() const{
		return Vector(x+w/2,y+h/2);
	}
};

} // namespace GrobMaker

#endif //#ifndef GROBMAKER_AREA
